#include "IResource.h"
#include "ResourceManager.h"

namespace glow
{
	using namespace std;

	IResource::IResource(string name) : _name(name), _counter(1)
	{
		ResourceManager::getInstance()->add(this);
	}

	IResource::~IResource() {}

	void IResource::addRef()
	{
		_counter++;
	}

	void IResource::release()
	{
		_counter--;
		if(_counter == 0)
		{
			ResourceManager::getInstance()->remove(_name);
			delete this;
		}
	}
	
	string IResource::getName()
	{
		return _name;
	}
}
